package com.zjcloud.jwgl.domain;

import com.zjcloud.common.annotation.Excel;
import com.zjcloud.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 约束类型对象
 * 定义排课系统中的各种约束类型
 *
 * @author zjcloud
 * @since 2024-01-01
 */
public class AcConstraintType extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /** 主键ID */
    private Long id;

    /** 约束类型编码，唯一标识 */
    @Excel(name = "约束类型编码")
    @NotBlank(message = "约束类型编码不能为空")
    private String typeCode;

    /** 约束类型名称 */
    @Excel(name = "约束类型名称")
    @NotBlank(message = "约束类型名称不能为空")
    private String typeName;

    /** 约束分类：HARD-硬约束，SOFT-软约束 */
    @Excel(name = "约束分类")
    @NotBlank(message = "约束分类不能为空")
    private String category;

    /** 约束描述 */
    @Excel(name = "约束描述")
    private String description;

    /** 默认权重(1-100) */
    @Excel(name = "默认权重")
    @NotNull(message = "默认权重不能为空")
    private Integer defaultWeight;

    /** 是否系统内置：1-是，0-否 */
    @Excel(name = "是否系统内置")
    private String isSystem;

    /** 是否启用：1-启用，0-禁用 */
    @Excel(name = "是否启用")
    private String enabled;

    /** 排序号 */
    @Excel(name = "排序号")
    private Integer sortOrder;

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setTypeCode(String typeCode) {
        this.typeCode = typeCode;
    }

    public String getTypeCode() {
        return typeCode;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getCategory() {
        return category;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public void setDefaultWeight(Integer defaultWeight) {
        this.defaultWeight = defaultWeight;
    }

    public Integer getDefaultWeight() {
        return defaultWeight;
    }

    public void setIsSystem(String isSystem) {
        this.isSystem = isSystem;
    }

    public String getIsSystem() {
        return isSystem;
    }

    public void setEnabled(String enabled) {
        this.enabled = enabled;
    }

    public String getEnabled() {
        return enabled;
    }

    public void setSortOrder(Integer sortOrder) {
        this.sortOrder = sortOrder;
    }

    public Integer getSortOrder() {
        return sortOrder;
    }

    /**
     * 判断是否为硬约束
     */
    public boolean isHardConstraint() {
        return "HARD".equals(this.category);
    }

    /**
     * 判断是否为软约束
     */
    public boolean isSoftConstraint() {
        return "SOFT".equals(this.category);
    }

    /**
     * 判断是否为系统内置约束
     */
    public boolean isSystemConstraint() {
        return "1".equals(this.isSystem);
    }

    /**
     * 判断是否启用
     */
    public boolean isEnabled() {
        return "1".equals(this.enabled);
    }

    /**
     * 获取约束分类描述
     */
    public String getCategoryDesc() {
        switch (category) {
            case "HARD":
                return "硬约束";
            case "SOFT":
                return "软约束";
            default:
                return "未知";
        }
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("typeCode", getTypeCode())
                .append("typeName", getTypeName())
                .append("category", getCategory())
                .append("description", getDescription())
                .append("defaultWeight", getDefaultWeight())
                .append("isSystem", getIsSystem())
                .append("enabled", getEnabled())
                .append("sortOrder", getSortOrder())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .append("remark", getRemark())
                .toString();
    }
}